<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <div id='showTime'></div>
    <script>
          var timer = null;

            function displayWeek(index){
                var weeks= ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];

                return weeks[index];

            }
          function displayTime(){
              var showTime=document.getElementById("showTime");
              var now =new Date();
              var year=now.getFullYear();
              var month=(now.getMonth()+1).toString().padStart(2,"0");
              var date=now.getDate().toString().padStart(2,"0");
              var day=now.getDay().toString().padStart(2,"0");
              var hour=now.getHours().toString().padStart(2,"0");
              var miunte= now.getMinutes().toString().padStart(2,"0");
              var second=now.getSeconds().toString().padStart(2,"0");
              var week=displayWeek(date);
              var time=getAMOrPM(hour);
              showTime.innerHTML=`${year}年${month}月${date}日${hour}:${miunte}:${second}:${time} ${week}`;
              timer=window.setTimeout(displayTime,1000);
          }
          function getAMOrPM(hour){
            if(hour<12){
                return "AM";
            }
            return "PM";
          }
          displayTime();
    </script>
</body>
</html>